# -*- coding: utf-8 -*-

'''
Created on 24/02/2009

@author: vincent.vanghelle
'''

from django.db import models

from mmorganizer.games.models import Game,Role,Class,Serveur
from django.contrib.auth.models import User

class Personnage(models.Model):
    game = models.ForeignKey(Game)
    serveur = models.ForeignKey(Serveur)
    classe = models.ForeignKey(Class)
    role = models.ForeignKey(Role)
    name = models.CharField(max_length=50)
    user = models.ForeignKey(User)
    def __unicode__(self):
        return self.name
    
    class Meta:
        unique_together = (("game", "serveur","name"))
        ordering = ('game','serveur','name')


class Roster(models.Model):
    game = models.ForeignKey(Game)
    serveur = models.ForeignKey(Serveur)
    name = models.CharField(max_length=50)
    responsable = models.ForeignKey(User,related_name='responsable')
    membres = models.ManyToManyField(Personnage,related_name='rosters')
    membresEnAttente = models.ManyToManyField(Personnage,related_name='rostersEnAttente')
    admins = models.ManyToManyField(Personnage,related_name='adminRosters')
    def __unicode__(self):
        return self.name
    
    class Meta:
        unique_together = (("game", "serveur","name"))
        ordering = ('game','serveur','name')